import request from "@/api/config/request.ts"
import type { ApiResponse } from "@/api/type.ts"
import type { RoleStructure } from "@/api/role.ts"

export interface UserLoginStructure {
  id: number
  username: string
  password: string
  role: RoleStructure[]
  roleIds?: number[]
}

export interface UserLoginData {
  username: string
  password: string
}

export interface LoginResponse {
  token: string
}

// 登录接口
export const loginApi = async (
  data: UserLoginData
): Promise<ApiResponse<LoginResponse>> => {
  return request.post("/login/login", data)
}
